Avoid a warning when persisting clipboards
authorMatthias Clasen <mclasen@redhat.com>
Sun, 17 May 2009 22:35:51 +0000 (18:35 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 18 May 2009 00:41:50 +0000 (20:41 -0400)
Correctly handle conversion to SAVE_TARGETS as a side-effect target
with no side-effect, by returning a zero-sized property of type NULL.
See section 2.6.3 of the ICCCM.

gtk/gtkselection.c

index 6b22c32cc728e25e10d4fa189c2e5cc5cd293410..4c4ab7301c90e56da8b66201b6c5d432b0dc4c54 100644 (file)
@@ -94,6 +94,7 @@ enum {
   MULTIPLE,
   TARGETS,
   TIMESTAMP,
+  SAVE_TARGETS,
   LAST_ATOM
 };
 
@@ -2172,6 +2173,7 @@ gtk_selection_init (void)
   gtk_selection_atoms[MULTIPLE] = gdk_atom_intern_static_string ("MULTIPLE");
   gtk_selection_atoms[TIMESTAMP] = gdk_atom_intern_static_string ("TIMESTAMP");
   gtk_selection_atoms[TARGETS] = gdk_atom_intern_static_string ("TARGETS");
+  gtk_selection_atoms[SAVE_TARGETS] = gdk_atom_intern_static_string ("SAVE_TARGETS");
 
   initialize = FALSE;
 }
@@ -2377,7 +2379,6 @@ _gtk_selection_request (GtkWidget *widget,
 #endif
       
       gtk_selection_invoke_handler (widget, &data, event->time);
-      
       if (data.length < 0)
        {
          info->conversions[i].property = GDK_NONE;
@@ -2968,7 +2969,8 @@ gtk_selection_invoke_handler (GtkWidget          *widget,
   g_return_if_fail (widget != NULL);
 
   target_list = gtk_selection_target_list_get (widget, data->selection);
-  if (target_list && 
+  if (data->target != gtk_selection_atoms[SAVE_TARGETS] &&
+      target_list &&
       gtk_target_list_find (target_list, data->target, &info))
     {
       g_signal_emit_by_name (widget,
@@ -3061,6 +3063,12 @@ gtk_selection_default_handler (GtkWidget *widget,
          tmp_list = tmp_list->next;
        }
     }
+  else if (data->target == gtk_selection_atom[SAVE_TARGETS])
+    {
+      gtk_selection_data_set (data,
+                             gdk_atom_intern_static_string ("NULL"),
+                             32, "", 0);
+    }
   else
     {
       data->length = -1;